<template>
  <div class="list-parent">
    <div class="list-content" v-for="(items, indexs) in exList" :key="indexs">
      <img class="wrapper-title-img3" :src="publicUrls + 'customized/zjz/unitIcon20.png'" alt="" />
      <div
        class="exhibits-item"
        :class="{ 'exhibits-item-1': (index + 1) % 2 === 0 }"
        v-for="(item, index) in items"
        :key="index"
      >
        <div class="item-content" @click="lookExibit(item.id)">
          <div class="item-cover">
            <img :src="$filters.getLinkUrl(item.coverUrl, '?imageView2/3/format/webp')" alt="" />
          </div>
          <div class="btm-name" :style="{ backgroundImage: `url(${publicUrls + 'customized/zjz/unitIcon21.png'})` }">
            <span>{{ item.name }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template> 
 
<script setup lang="ts">
import { watch, ref, reactive } from 'vue';
import { publicUrls } from '@/utils/minxin';
const props = defineProps({
  list: {
    type: Object,
  },
});
const emit = defineEmits(['emitItemId']);
const exList = ref([]);
const cancatList = ref([]);
const init = () => {
  exList.value = [];
  cancatList.value = [];
  props.list.forEach((element, index) => {
    if ((index + 1) % 2 === 0) {
      cancatList.value.push(element);
      exList.value.push(cancatList.value);
      cancatList.value = [];
    } else {
      cancatList.value.push(element);
    }
  });
  console.log(exList.value, '11111111111111');
};
watch(
  () => props.list,
  () => {
    init();
  },
  { deep: true },
);
const lookExibit = (e: number) => {
  emit('emitItemId', e);
};
</script> 

<style lang="scss" scoped>
.list-parent {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 343px;
  margin: 0 auto;
}
.list-content {
  position: relative;
  display: flex;
  justify-content: center;
  width: 343px;
  height: 170px;
  margin-bottom: 24px;
}
.exhibits-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 140px;
  height: 170px;
}
.exhibits-item-1 {
  margin-left: 20px;
}
.item-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 130px;
}
.item-cover {
  display: flex;
  align-items: flex-end;
  width: 130px;
  height: 130px;
  img {
    width: 130px;
    height: auto;
    max-height: 130px;
  }
}
.btm-name {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 26px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding: 4px 8px;
  margin-top: 10px;
  span {
    width: 100%;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: SourceHanSerifCN-medium;
    font-weight: 500;
    font-size: 13px;
    color: #333333;
    line-height: 21px;
  }
}
.wrapper-title-img3 {
  position: absolute;
  left: 0px;
  bottom: 30px;
  width: 343px;
  height: 37.68px;
}
</style>